import numpy as np
import numpy.linalg as LA

npyf = "../dcsc_mat_n1000_nnz299576.npy"
resf = [
		"dcsc_mat_n1000_nnz299576.bin_k100.res",
		"dcsc_mat_n1000_nnz299576.bin_k200.res",
		"dcsc_mat_n1000_nnz299576.bin_k400.res",
		"dcsc_mat_n1000_nnz299576.bin_k800.res",
		"dcsc_mat_n1000_nnz299576.bin_k1000.res",
		"dcsc_mat_n1000_nnz299576.bin_k10000.res",
		"dcsc_mat_n1000_nnz299576.bin_k20000.res",
		"dcsc_mat_n1000_nnz299576.bin_k40000.res",
		]
n = 1000
A = np.load(npyf)


print "L1\tL2"
for file in resf :
	B = np.matrix(np.zeros(1000*1000).reshape((n,n)))
	f = open(file)
	for line in f :
		line = line.split('\t')
		B[line[0],line[1]] = line[2]

	C = A-B

	L1 = LA.norm(C,1) / LA.norm(A, 1)
	L2 = LA.norm(C,2) / LA.norm(A, 2)
	print L1, "\t", L2